package cn.creditease.std.monitor.impl;

import cn.creditease.std.consumer.JobConsumer;
import cn.creditease.std.consumer.JobConsumerRegistory;
import cn.creditease.std.monitor.AbstractRepairMonitor;
import java.util.concurrent.TimeUnit;

/**
 * @Description: 补偿任务检查器
 * @Author: kai.yang
 * @Date: 2019-08-08 11:35
 */
public class RepairCheckJobMonitor extends AbstractRepairMonitor {


    public RepairCheckJobMonitor(String jobName) {
        super(jobName);
    }

    @Override
    public void check() {
        scheduledThreadPoolExecutor.scheduleAtFixedRate(() ->
            {

                try {
                    JobConsumer jobConsumer = JobConsumerRegistory.getConsumer(getJobName());
                    if (jobConsumer != null) {
                        jobConsumer.consume(getJobName());
                    }
                } catch (Exception e) {
                }
            },
            60, 60*3, TimeUnit.SECONDS);

    }


}
